package com.example.servletDemo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet(urlPatterns = "/customerTag")
public class customerTagServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setAttribute("header",getHeader());
        req.setAttribute("body",getBody());
        req.setAttribute("name","sharif");
        req.getRequestDispatcher("/customerTag.jsp").forward(req,resp);
    }

    public List<String> getHeader()
    {
        List<String> header  = new ArrayList<>();
        header.add("first");
        header.add("second");
        return header;
    }

    public List<List<String>> getBody()
    {
        List<List<String>> body  = new ArrayList<>();
        List<String> firstBody = new ArrayList<>();
        firstBody.add("1");
        firstBody.add("2");
        body.add(firstBody);
        List<String> secondBody = new ArrayList<>();
        secondBody.add("1");
        secondBody.add("2");
        body.add(secondBody);
        return body;
    }
}
